<html>
	{% include "../common_head.html" %}
	<body>
	{% include "../common_menus.html" %}
	
		<div id="rakontu_form_style" class="rakontu_form">
		<form action="/{{dir_manage}}/{{url_questions}}_{{refer_type_url}}?{{rakontu.urlQuery}}" method="post" enctype="multipart/form-data">

		{% if changes_saved %}
			<div class="message">{{template_changes_saved}}</div>
		{% endif %}
		
		<h3>{{template_add_new_questions_about}} {{refer_type_plural_display}} {{"adding_new_questions"|tip}}</h3>
		<fieldset>
		<textarea name="newQuestionNames" rows="6" cols="40"></textarea>
		</fieldset>

		{% if questions %}
			<h3>{{template_change_questions_about}} {{refer_type_plural_display}} {{"inactive_questions"|caution}}</h3>
			<fieldset>
	      	<table cellpadding="0" cellspacing="0"  style="border:none;">
	      		{% for question in questions %}
	      			<tr>
 					<td style="border:none;">
 						{% if question.active %}
 	      					<input type="submit" class="active" value="" name="inactivate|{{question.key}}" title="{{template_inactivate}}"></td>
 						{% else %}
 	      					<input type="submit" class="inactive" value="" name="activate|{{question.key}}" title="{{template_activate}}"></td>
 						{% endif %}
 					</td>
	      			<td style="border:none;">
	      				{% if not questions|isFirstInSeries:question %}
	      					<input type="submit" class="move_up" value="" name="moveUp|{{question.key}}" title="{{template_move_up}}"></td>
	      				{% else %}
	      					&nbsp;
	      				{% endif %}
	      			<td style="border:none;">
	      				{% if not questions|isLastInSeries:question %}
	      					<input type="submit" class="move_down" value="" name="moveDown|{{question.key}}" title="{{template_move_down}}"></td>
 						{% else %}	
 							&nbsp;
 						{% endif %}
      				<td style="border:none;">
      					<p><b>{{question.linkString}}</b> ({{term_answers}}: {{question.getAnswerCount}})</p>
      					<p>{{question.name}} - {{question.type}} 
      					{% if question.isOrdinalOrNominal %}
      						{% if question.choices %}
      							- {{question.choices|join:", "}}
      						{% endif %}
      						{% if question.multiple %}
      							({{template_multiple}})
      						{% endif %}
      					{% endif %}
      					</p>
      				</td>
	      				</tr>
	      		{% endfor %}
	      	</table>
	      	</fieldset>
	    {% endif %}
	      	
	    <h3>{{template_import_export_questions_about}} {{refer_type_plural_display}}</h3>
	    <fieldset>
	    <p>{{template_choose_csv_question_file}}:
	    <input type="file" name="import" size="40" accept="csv"/></p>
	    {% if questions %}
	    	<p><a href="/{{dir_manage}}/{{url_questions_to_csv}}?{{url_query_export_type}}={{refer_type_plural_display}}&{{rakontu.urlQuery}}">{{template_export_questions_to_csv}}</a></p>
	    {% endif %}
	    </fieldset>

	    {% if system_questions %}
			<h3>{{template_copy_sample_questions_about}} {{refer_type_plural_display}} {{"copying_sample_questions"|tip}}</h3>
			<fieldset>
	      	<table border="0" cellpadding="4" cellspacing="0">
	      	<tr>
	      		<th>{{template_copy}}?</th>
	      		<th>{{template_question}}</th>
	      		</tr>
				{% for sys_question in system_questions %}
	      			<td valign="top" width="80"><input type="checkbox" name="copy|{{sys_question.key}}" value="copy|{{sys_question.key}}" id="copy|{{sys_question.key}}">
	      			<label for="copy|{{sys_question.key}}">{{template_copy}}</label></td>
					<td valign="top">
					<b>{{sys_question.text}}</b> ({{sys_question.name}})
					{{template_is_of_the_type}} <b>{{sys_question.type}}</b>.
					{% ifequal sys_question.type "value" %} 
						{{template_min_max_are}} {{sys_question.minIfValue}} - {{sys_question.maxIfValue}}. 
					{% endifequal %}
					{% ifequal sys_question.type "boolean" %} 
						{{template_a_positive_answer_is}}: {{sys_question.positiveResponseIfBoolean}}.
						{{template_a_negative_answer_is}}: {{sys_question.negativeResponseIfBoolean}}.
					{% endifequal %}
					{% ifequal sys_question.type "ordinal" %}
						{{template_choices_are}}:
						<ol>
						{% for choice in sys_question.choices %}
							<li>{{choice}}</li>
						{% endfor %}
						</ol>
					{% endifequal %}
					{% ifequal sys_question.type "nominal" %}
						{{template_choices_are}}:
						<ul>
						{% for choice in sys_question.choices %}
							<li>{{choice}}</li>
						{% endfor %}
						</ul>
					{% endifequal %}
					{% if sys_question.multiple %} 
						{{template_multiple_answers_allowed}} 
					{% endif %}
					{% if sys_question.help %} 
						{{template_explanation_is}} "{{sys_question.help}}" 
					{% endif %}
					</td>
					</tr>
				{% endfor %}
				</table>
				</fieldset>
			{% endif %}

		<p>
    <center><input type="submit" name="changesTo|{{refer_type}}" value="{{button_save_changes}}" class="button"/></center>
	</form>	
	</div>

	</div>
	{% include "../common_footer.html" %}
	</body>
</html>
